package com.api.shopapi.service.impl;

import com.api.shopapi.entity.Berth;
import com.api.shopapi.entity.dto.BerthCountDTO;
import com.api.shopapi.mapper.BerthMapper;
import com.api.shopapi.service.BerthService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author maochuan
 */
@Service("BerthServiceImplOne")
public class BerthServiceImpl implements BerthService {

    @Autowired
    private BerthMapper berthMapper;

    @Override
    public int insert(Berth berth) {
        return berthMapper.insert(berth);
    }

    @Override
    public int updateByBerthCode(Berth berth) {
        return berthMapper.updateByBerthCode(berth);
    }

    @Override
    public int deleteByBerthCode(String berthCode) {
        return berthMapper.deleteByBerthCode(berthCode);
    }

    @Override
    public List<Berth> getListAll() {
        return berthMapper.getListAll();
    }

    @Override
    public Berth getByBerthCode(String berthCode) {
        return berthMapper.getByBerthCode(berthCode);
    }

    @Override
    public Berth getByNumber(String number, String roomCode, String institutionCode) {
        return berthMapper.getByrNumber(number,roomCode,institutionCode);
    }

    @Override
    public PageInfo<Berth> getPageList(int pageIndex, int pageSize, String institutionCode, int number, String roomCode,int status) {
        PageHelper.startPage(pageIndex, pageSize);
        List<Berth> berths = berthMapper.getPageList(institutionCode,number,roomCode,status);
        PageInfo<Berth> pageInfo = new PageInfo<Berth>(berths);
        return pageInfo;
    }

    @Override
    public List<Berth> getListByRoomCode(String roomCode) {
        return berthMapper.getListByRoomCode(roomCode);
    }


    @Override
    public List<Berth> getListByRoomCodeAndStatus0(String roomCode) {
        return berthMapper.getListByRoomCodeAndStatus0(roomCode);
    }

    @Override
    public List<Berth> getListByRoomCodeAndStatusNot11(String roomCode) {
        return berthMapper.getListByRoomCodeAndStatusNot11(roomCode);
    }

    @Override
    public Berth getByName(String name, String roomCode, String institutionCode) {
        return berthMapper.getByName(name,roomCode,institutionCode);
    }

    @Override
    public BerthCountDTO getBerthNumByIns(List<String> institutionCode) {
        return berthMapper.getBerthNumByIns(institutionCode);
    }



    //机构床位总数
    @Override
    public
    List<Berth> ListByInstitutionCode(String institutionCode){
        return berthMapper.ListByInstitutionCode(institutionCode);
    }

    //已入住床位总数
    @Override
    public
    List<Berth> ListCheckinByInstitutionCode(String institutionCode){
        return berthMapper.ListCheckinByInstitutionCode(institutionCode);
    }

    @Override
    public
    PageInfo<Berth> pageByGovCode(int pageIndex, int pageSize, String governmentCode){
        PageHelper.startPage(pageIndex, pageSize);
        List<Berth> berths = berthMapper.listByGovCode(governmentCode);
        PageInfo<Berth> pageInfo = new PageInfo<Berth>(berths);
        return pageInfo;
    }


}
